﻿using huaxin_core;
using huaxin_Impl;
using huaxin_Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace huaxin_luckdraw.Controllers
{
    public class LuckController : Controller
    {
        // GET: Luck
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Next()
        {
            return View();
        }

        public JsonResult Star()
        {
            var result = new JsonResult();
            huaxin_ILuckDraw _luckDraw = new huaxin_LuckDrawImpl();
            var luckdraws = _luckDraw.GetLuckdrawAll();
            if (luckdraws.Count > 0)
            {
                var commodity = LuckDrawHelp.SendLuckdraw(luckdraws);
                result.Data = new { state = 1, message = commodity.PrizeName, obj = commodity.PrizeId - 1001 };
            }
            else
            {
                result.Data = new { state = 0, message = "系统错误！", obj = 0 };
            }

            return result;
        }
    }
}